﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml;
using WebServiceKFC.Model;
using WebServiceKFC.Utils;

namespace WebServiceKFC.MonAnF
{
    public abstract class MonAnDTO
    {
        protected string _maMonAn;

        public string MaMonAn
        {
            get { return _maMonAn; }
            set { _maMonAn = value; }
        }

        protected string _tenMonAn;

        public string TenMonAn
        {
            get { return _tenMonAn; }
            set { _tenMonAn = value; }
        }

        protected int _donGia;

        public int DonGia
        {
            get { return _donGia; }
            set { _donGia = value; }
        }

        protected string _chiTietMonAn;

        public string ChiTietMonAn
        {
            get { return _chiTietMonAn; }
            set { _chiTietMonAn = value; }
        }

        protected int _soLuong;

        public int SoLuong
        {
            get { return _soLuong; }
            set { _soLuong = value; }
        }

        protected string _loaiDoiTuong;

        public string LoaiDoiTuong
        {
            get { return _loaiDoiTuong; }
            set { _loaiDoiTuong = value; }
        }

        virtual public XmlDocument GetExtraAttributes()
        {
            return UtilsXMLDTO.PortExAttToXML();
        }

        public SafeMonAnDTO GetSafeInfo()
        {
            SafeMonAnDTO kq = new SafeMonAnDTO();
            kq.Attach(this);
            return kq;
        }

        public virtual string LayTenLoaiDoiTuong()
        {
            return null;
        }

        public virtual MonAnDTO Clone()
        {
            return null;
        }



        public virtual void SetInforFrom(Model.MonAn i)
        {
            ChiTietMonAn = i.ChiTiet;
            DonGia = (int)i.DonGia;
            LoaiDoiTuong = i.LoaiDoiTuong;
            MaMonAn = i.MaMonAn;
            SoLuong = (int)i.SoLuong;
            TenMonAn = i.TenMonAn;
        }

        public virtual void SetInforFrom(SafeMonAnDTO safeMonAn)
        {
            ChiTietMonAn = safeMonAn.ChiTietMonAn;
            DonGia = safeMonAn.DonGia;
            LoaiDoiTuong = safeMonAn.LoaiDoiTuong;
            MaMonAn = safeMonAn.MaMonAn;
            SoLuong = safeMonAn.SoLuong;
            TenMonAn = safeMonAn.TenMonAn;
        }

        public virtual void Save(Model.DatabaseKFCEntities db, MonAn monAn)
        {
            monAn.ChiTiet = ChiTietMonAn;
            monAn.DonGia = DonGia;
            monAn.LoaiDoiTuong = LoaiDoiTuong;
            monAn.MaMonAn = MaMonAn;
            monAn.SoLuong = SoLuong;
            monAn.TenMonAn = TenMonAn;
            db.AddToMonAns(monAn);
            db.SaveChanges();
        }
    }
}